<!DOCTYPE html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <title>jeesite地图</title>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=3.0&ak=RxQAVLCAbVmxAqKL0iuNjXNr"></script>
    <script src="${ctxStatic}/jquery/jquery-1.12.4.min.js"></script>
    <script src="${ctxStatic}/common/BaiduMapJS.js"></script>
    <style type="text/css">
        body, html,#container {width: 100%;height: 100%;overflow: hidden;margin:0;font-family:"微软雅黑";}
    </style>
    <style type="text/css">
        .anchorBL{  display:none; }
    </style>
</head>
<body>
<div id="container"></div>
</body>
</html>
<script type="text/javascript">
    $(document).ready(function(){
        initMap();
    });
    function initMap(){
        var mp = new BMap.Map("container");
        mp.centerAndZoom(new BMap.Point(107.150824,38.650653), 5);

        //添加滚动效果
        BaiduMapJS.enableScrollWheelZoom(mp);
        //移除地图上的公路和铁路
        BaiduMapJS.removeRoadFromMap(mp)

        $.ajax({
            type: 'POST',
            url: "${ctx}" + "/point/index",
            data: {},
            dataType: 'json',
            async: false,
            error: function(data){
                js.showErrorMessage(data.responseText);
            },
            success: function(data, status, xhr){
                for(var d in data.data){
                    var info = data.data[d];
                    var marker = new BMap.Marker(new BMap.Point(info.longitude, info.latitude));
                    openInfoWindow(info,mp,marker);
                    mp.addOverlay(marker);
                }

            }
        });
    }
    //打开新窗口
    function openInfoWindow(info,mp,marker){
        marker.addEventListener("click",function(e){
            // openInfoWindow(info,mp)
            var opts = {
                width: 250,     // 信息窗口宽度
                height: 80,     // 信息窗口高度
                title: "信息窗口", // 信息窗口标题
                enableMessage: true//设置允许信息窗发送短息
            }

            var point = new BMap.Point(info.longitude, info.latitude);
            var infoWindow = new BMap.InfoWindow(info.remarks,opts);  // 创建信息窗口对象
            mp.openInfoWindow(infoWindow,point); //开启信息窗口
        });
    }
</script>
